<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>watch深度deep练习</title>
    <script src="../../js/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <button v-on:click="add">点击</button>
    </div>
    <script>
      var v_app = new Vue({
        el: "#app",
        data: {
          obj: {
            name1: "邮箱",
            name2: "诺亚",
            name3: "小雪",
            name4: "毁灭菇",
          },
        },
        methods: {
          add: function () {
            this.obj.name1 = this.obj.name1 + "1";
          },
        },
        watch: {
          obj: {
            handler: function (news) {
              console.log("属性发生了变化: " + news.name1);
            },
            deep: true,
          },
        },
      });
    </script>
  </body>
</html>
